@model UI.Models.GameDisplay
@{
    ViewBag.Title = "Game Details";
}

<h2>Details</h2>

<fieldset>
    <legend>Game</legend>

    <div id="exception">@Html.DisplayFor(model => model.Error)</div>

    <div class="display-label">Game Date</div>
    <div class="display-field">@Html.DisplayFor(model => model.GameDate)</div>

    <div class="display-label">Game Time</div>
    <div class="display-field">@Html.DisplayTextFor(model => model.GameTime)</div>

    <div class="display-label">Status</div>
    <div class="display-field">@Html.DisplayTextFor(model => model.GameStatus).ToString()</div>

    <div class="display-label">Currently Playing</div>
    <div class="display-field">@(Model.Playing == null ? "None" : Model.Playing.Count.ToString())

        <table>
            <tr>
                <th>Name
                </th>
            </tr>

            @foreach (var item in Model.Playing)
            {
                <tr>
                    <td>
                        @Html.DisplayTextFor(_ => item.Name)
                    </td>
                </tr>
            }
        </table>
    </div>

    <div class="display-label">Currently Substituting</div>
    <div class="display-field">@(Model.Playing == null ? "None" : Model.Substitutions.Count.ToString())

        <table>
            <tr>
                <th>Name
                </th>
            </tr>

            @foreach (var item in Model.Substitutions)
            {
                <tr>
                    <td>
                        @Html.DisplayTextFor(_ => item.Name)
                    </td>
                </tr>
            }
        </table>
    </div>

    <div class="display-label">Status</div>
    <div class="display-field">@Html.DisplayTextFor(_ => Model.GameStatus).ToString()</div>
</fieldset>
<p>
    @if (Model != null && Model.GameStatus.Equals(Domain.GameStatus.Created.ToString()))
    {
        @Html.ActionLink("Publish Game", "Publish", new { id = Model.GameId }) 
    }
    @if (Model != null && Model.GameStatus.Equals(Domain.GameStatus.Published.ToString()))
    {
        @Html.ActionLink("Add Player", "AddPlayer", new { id = Model.GameId })
    }
    @Html.ActionLink("Back to List", "Index")
</p>


